// 防抖
export let debounce = function (func, delay){
    let timerId;
    return function() {
      clearTimeout(timerId);
      timerId = setTimeout(() => {
        func.apply(this, arguments);
      }, delay);
    }
}


export let debounceFn=function (callback, duration) {
  let debounceTimer = null;
  return function (...args) {
    let ctx = this;
    if (debounceTimer) clearTimeout(debounceTimer);
    debounceTimer = setTimeout(() => {
      console.log('定时器函数执行了')
      callback.apply(ctx, args);
    }, duration);
  };
};
